const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('base_enterprise_intelligence', {
    id: {
      autoIncrement: true,
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "唯一标识"
    },
    certid: {
      type: DataTypes.STRING(100),
      allowNull: false,
      primaryKey: true,
      comment: "资质证书编号"
    },
    corpcode: {
      type: DataTypes.STRING(30),
      allowNull: false,
      comment: "组织机构代码"
    },
    certtypenum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "资质类型代码"
    },
    titleleveinum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "资质最高等级代码"
    },
    ctoidcardtypenum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "技术负责人身份证件类型"
    },
    ctoidcard: {
      type: DataTypes.STRING(30),
      allowNull: true,
      comment: "技术负责人身份证件号码"
    },
    ctospecialtytypnum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "技术负责人注册类型及等级代码"
    },
    ceoidcardtypenum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "企业负责人身份证件类型"
    },
    ceoidcard: {
      type: DataTypes.STRING(30),
      allowNull: true,
      comment: "企业负责人身份证件号码"
    },
    cfoidcardtypenum: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "财务负责人身份证件类型"
    },
    cfoidcard: {
      type: DataTypes.STRING(30),
      allowNull: true,
      comment: "财务负责人身份证件号码"
    },
    organname: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: "发证机关"
    },
    organdate: {
      type: DataTypes.DATEONLY,
      allowNull: true,
      comment: "发证日期"
    },
    enddate: {
      type: DataTypes.DATEONLY,
      allowNull: true,
      comment: "证书有效期"
    },
    isvalid: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "证书状态代码"
    },
    description: {
      type: DataTypes.STRING(1000),
      allowNull: true,
      comment: "备注"
    },
    isDeleted: {
      type: DataTypes.TINYINT,
      allowNull: true,
      comment: "是否删除",
      field: 'is_deleted'
    },
    createdUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "创建人",
      field: 'created_user'
    },
    createdTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "本系统创建时间",
      field: 'created_time'
    },
    updatedUser: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "修改人",
      field: 'updated_user'
    },
    updatedTime: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "修改时间",
      field: 'updated_time'
    }
  }, {
    sequelize,
    tableName: 'base_enterprise_intelligence',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
          { name: "certid" },
        ]
      },
      {
        name: "fk",
        using: "BTREE",
        fields: [
          { name: "corpcode" },
        ]
      },
      {
        name: "certid",
        using: "BTREE",
        fields: [
          { name: "certid" },
        ]
      },
    ]
  });
};
